package com.hxl.demo.controller;

import com.hxl.demo.entity.Staff;
import com.hxl.demo.service.Impl.StaffServiceImpl;
import com.hxl.demo.tools.Common;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.validation.Valid;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class StaffController {

    @Resource
    private StaffServiceImpl staffService;

    @RequestMapping("/staffList")
    public Object getStaffList(@RequestParam(name = "page",required = false) Integer page,
                               @RequestParam(name = "limit",required = false) Integer limit,
                               @RequestParam(name = "userName",required = false) String userName,
                               @RequestParam(name = "pinName",required = false) String pinName,
                               @RequestParam(name = "deptName",required = false) String deptName,
                               @RequestParam(name = "accountType",required = false) String accountType,
                               @RequestParam(name = "tel",required = false) String tel,
                               @RequestParam(name = "id",required = false) Integer id
                               ){


        List<Staff> staffList= staffService.getStaffList( limit, page, userName, pinName, deptName, accountType, tel,id);
        Integer num=staffService.getStaffNum(userName, pinName, deptName, accountType, tel);

        return Common.returnJsonList("操作成功",200,staffList,num);

    }
    @RequestMapping("staffAdd")
    public Object staffAdd(@Valid Staff staff){
        return staffService.staffAdd(staff);

    }
    @RequestMapping("staffUpdate")
    public Object staffUpdate(@Valid Staff staff){
        return staffService.staffUpdate(staff);

    }
    @RequestMapping("staffDel")
    public Object staffUpdate(  @RequestParam(name = "id") Integer id){
        return staffService.staffDel(id);

    }



}
